extends Control



#onready var name_input = $editaModal/VBoxContainer/name/LineEdit
#onready var desc_input = $editaModal/VBoxContainer/desc/LineEdit



var ItemColumu = preload("res://tool/page/item/ItemColumu.tscn")

onready var search_input = $searchBox/LineEdit

# 当前正在编辑的剧本数据，添加剧本数据为空
var edit_drama_data = null


func _ready():
	state_update()

# 刷新页面状态
func state_update():
	update_list(DataSource.get_serie_item_list())
	

func update_list(list):
	var box = $table/ScrollContainer/VBoxContainer
	
	for child in box.get_children():
		child.queue_free()
		

	for data in list:
		var ui_item = ItemColumu.instance()
		ui_item.set_data(data)
		box.add_child(ui_item)


func _on_search_button_up():
	var text = search_input.text
	
	if text:
		var list = []
		for map in DataSource.get_serie_item_list():
			if map["name"].find(text) != -1:
				list.append(map)
				
		update_list(list)
	else:
		update_list(DataSource.get_serie_item_list())
